package Day5.ZuoYe;

import java.text.SimpleDateFormat;
import java.util.Calendar;

//6：学士后结业考试的时间是每月倒数第二个周六上午8点，输出今年的考试时间 ，用yyyy/MM/dd hh时 的格式输出
public class ZuoYe6 {
    public static void main(String[] args) {
        Calendar c = Calendar.getInstance();
        SimpleDateFormat sim = new SimpleDateFormat("yyyy/MM/dd 08:00:00");
        c.set(2022, 0, 1);
        for (int j = 0; j < 12; j++) {
            int count = 0;
            boolean w = false;
            for (int i = 1; i <= c.get(Calendar.DAY_OF_MONTH); i++) {
                if (c.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) {
                    if (i <= 2 || (i == 3 && c.getActualMaximum(Calendar.DAY_OF_MONTH) == 31)) {
                        w = true;
                    }
                    if (w) {
                        if (count == Calendar.WEEK_OF_MONTH - 1) {
                            String s = sim.format(c.getTime());
                            System.out.println("今年的第" + (j + 1) + "次考试时间" + s);
                        }
                    } else {
                        if (count == Calendar.WEEK_OF_MONTH - 2) {
                            String s = sim.format(c.getTime());
                            System.out.println("今年的第" + (j + 1) + "次考试时间" + s);
                        }
                    }
                    count++;
                }
                c.add(Calendar.DAY_OF_MONTH, 1);
            }
        }
    }
}


